package com.ymatou.iapi.couponservice.testcase;

import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.couponservice.parameter.GetValidBatchesBySellerResp;
import com.ymatou.iapi.couponservice.parameter.GetValidBatchesBySellerResp.BatchVo;
import com.ymatou.iapi.couponservice.parameter.getValidBatchesBySellerBean;
import com.ymatou.iapi.couponservice.service.getValidBatchesBySellerCall;
import com.ymatou.iapi.m.couponservice.parameter.SellerCreateBatchBean;
import com.ymatou.iapi.m.couponservice.service.SellerCreateBatchCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponServiceMCallService;
import com.ymttest.utils.TestDataManager;
/**
*获取买手有效的批次列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getValidBatchesBySeller{
	private static getValidBatchesBySellerBean getvalidbatchesbysellerBean;
	private static getValidBatchesBySellerCall getvalidbatchesbysellerCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取买手有效的批次列表");
	}

	@Before
	public void caseUp() {
		getvalidbatchesbysellerBean=new getValidBatchesBySellerBean();
		getvalidbatchesbysellerCall=new getValidBatchesBySellerCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getvalidbatchesbysellerCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBatchesBySeller_001() {
		Logger.start(true,"获取买手有效的批次列表");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			CouponServiceMCallService couponServiceMCallService = new CouponServiceMCallService();
			
			SellerCreateBatchBean sellerCreateBatchBean1 = couponServiceMCallService.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall createCouponCall1= couponServiceMCallService.SellerCreateBatch(sellerCreateBatchBean1);		

			SellerCreateBatchBean sellerCreateBatchBean2 = couponServiceMCallService.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall createCouponCall2= couponServiceMCallService.SellerCreateBatch(sellerCreateBatchBean2);
			
			List<Integer> sellerIds = new ArrayList<Integer>();
	
			sellerIds.add(sellerCreateBatchBean1.getSellerId());
			sellerIds.add(sellerCreateBatchBean2.getSellerId());
			
			getvalidbatchesbysellerBean.setSellerIds(sellerIds);
			getvalidbatchesbysellerBean.setCouponType(1);
			
			getvalidbatchesbysellerCall.setData(getvalidbatchesbysellerBean);
			getvalidbatchesbysellerCall.callService();		
			
			Logger.verifyEquals("0", getvalidbatchesbysellerCall.getStatusCode1(), "验证返回statusCode");
			
			GetValidBatchesBySellerResp getValidBatchesBySellerResp = getvalidbatchesbysellerCall.GetValidBatchesBySellerResp();
			
			List<BatchVo> batchVoList = getValidBatchesBySellerResp.getBatchVoList();
			
			Logger.verifyEquals(sellerCreateBatchBean1.getSellerId(), batchVoList.get(0).getSellerId(), "验证返回sellerId");
			Logger.verifyEquals(sellerCreateBatchBean2.getSellerId(), batchVoList.get(1).getSellerId(), "验证返回sellerId");

			Logger.verifyEquals(createCouponCall1.getBatchCode(), batchVoList.get(0).getBatchCode(), "验证返回batchCode");
			Logger.verifyEquals(createCouponCall2.getBatchCode(), batchVoList.get(1).getBatchCode(), "验证返回batchCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBatchesBySeller_002() {
		Logger.start(true,"获取买手有效的批次列表-店铺分享券");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			CouponServiceMCallService couponServiceMCallService = new CouponServiceMCallService();
			
			SellerCreateBatchBean sellerCreateBatchBean1 = couponServiceMCallService.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean1.setCouponType((byte)2);
			sellerCreateBatchBean1.setEffectiveDays(2);
			SellerCreateBatchCall createCouponCall1= couponServiceMCallService.SellerCreateBatch(sellerCreateBatchBean1);		

			SellerCreateBatchBean sellerCreateBatchBean2 = couponServiceMCallService.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean2.setCouponType((byte)2);
			sellerCreateBatchBean2.setEffectiveDays(2);

			SellerCreateBatchCall createCouponCall2= couponServiceMCallService.SellerCreateBatch(sellerCreateBatchBean2);
			
			List<Integer> sellerIds = new ArrayList<Integer>();
	
			sellerIds.add(sellerCreateBatchBean1.getSellerId());
			sellerIds.add(sellerCreateBatchBean2.getSellerId());
			
			getvalidbatchesbysellerBean.setSellerIds(sellerIds);
			getvalidbatchesbysellerBean.setCouponType(2);
			
			getvalidbatchesbysellerCall.setData(getvalidbatchesbysellerBean);
			getvalidbatchesbysellerCall.callService();		
			
			Logger.verifyEquals("0", getvalidbatchesbysellerCall.getStatusCode1(), "验证返回statusCode");
			
			GetValidBatchesBySellerResp getValidBatchesBySellerResp = getvalidbatchesbysellerCall.GetValidBatchesBySellerResp();
			
			List<BatchVo> batchVoList = getValidBatchesBySellerResp.getBatchVoList();
			
			Logger.verifyEquals(sellerCreateBatchBean1.getSellerId(), batchVoList.get(0).getSellerId(), "验证返回sellerId");
			Logger.verifyEquals(sellerCreateBatchBean2.getSellerId(), batchVoList.get(1).getSellerId(), "验证返回sellerId");

			Logger.verifyEquals(createCouponCall1.getBatchCode(), batchVoList.get(0).getBatchCode(), "验证返回batchCode");
			Logger.verifyEquals(createCouponCall2.getBatchCode(), batchVoList.get(1).getBatchCode(), "验证返回batchCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
}